{include file="header/index" /}
<meta charset="UTF-8">
<style>
	.numYe {
		width: 50px;
		height: 30px;
		margin: 0 5px;
		border-radius: 3px;
		border: 1px solid #d9d9d9;
	}
	
	.numYeBtn {
		margin-left: 10px;
		padding: 5px 10px;
		border: 1px solid #d9d9d9;
		background: none;
		border-radius: 3px;
	}
</style>
<!--导航end-->
<div class="container bgwhite relative">
	<h2 class="container-title">操作日志</h2>
	<!-- <div class="mt20 operationTitle clearfix">
		<p class="fl  operationImg"><img src="__IMG__/sanLine.png"></p>
		<ul class="fl operationlog-center">
			<li class="fl operalogCurrent">全部</li>
			<li class="fl">我的日志</li>
			<li class="fl">今日日志</li>
			<li class="fl">本周日志</li>
			<li class="fl">本月日志</li>
		</ul>
	</div> -->

	<div class="mt20 operalogSearch clearfix">
		<form action="{:url('Log/index')}" method="get">
      		<div class="newBox">
				<div class="col-sm-3">
					<div class="col-sm-5 inputName">操作账号</div>
					<div class="col-sm-7">
						<input  type="text" value="{if condition='$admin_name'}{$admin_name}{/if}" name="admin_name" placeholder="请输入操作帐号" /></div>
				</div>
				<div class="col-sm-3">
					<div class="col-sm-5 inputName">开始时间</div>
					<div class="col-sm-7">
						<input type="text" id="datetimeStart" readonly class="form_datetime" name="starting_time" value="{if condition='$starting_time'}{$starting_time}{/if}" placeholder="起始时间">
					</div>
				</div>
				<div class="col-sm-3">
					<div class="col-sm-5 inputName">结束时间</div>
					<div class="col-sm-7">
						<input  type="text" id="datetimeEnd" readonly class="form_datetime" name="end_time" value="{if condition='$end_time'}{$end_time}{/if}" placeholder="结束时间">
					</div>
				</div>
				<div class="col-sm-3">
					<div class="col-sm-6">
							<button class="btn btn-primary input-Btn mr10 newBtnDefault newBtnPrimary">搜索</button>
					</div>
					<div class="col-sm-6">
							<button type="button" class="btn btn-default input-Btn fr newBtnDefault newBtnGray mt10 ml10" onclick="refresh()"><i class="fa fa-undo"></i>刷新</button>

					</div>
				</div>
			</div>

			<input type="hidden" value="{if condition='$admin_name'}{$admin_name}{/if}" id="admin_name" />
			<input type="hidden" value="{if condition='$starting_time'}{$starting_time}{/if}" id="starting_time" />
			<input type="hidden" value="{if condition='$end_time'}{$end_time}{/if}" id="end_time" />
		</form>
	</div>
	<div class="mt20 marginRL">
		<table class="table table-bordered">
			<thead>
				<tr>
					<th><input class="checkbAll" type="checkbox" name="all" value="" onclick="checkbAll(this)"></th>
					<th>ID</th>
					<th>操作帐号</th>
					<th>操作内容</th>
					<th>操作ip</th>
					<th>地址</th>
					<th>操作时间</th>
				</tr>
			</thead>
			<script id="list-template" type="text/html">
				{{# for(var i=0;i
				<d.length;i++){ }} <tr>
					<td><input class="Subpage" type="checkbox" name="Subpage" value="{{d[i].log_id}}"></td>
					<td>{{d[i].log_id}}</td>
					<td class="col-127">{{d[i].admin_name}}</td>
					<td>{{d[i].description}}</td>
					<td>{{d[i].ip}}</td>
					<td>{{d[i].ipaddr.country}} &nbsp{{d[i].ipaddr.area}}</td>
					<td>{{d[i].add_time}}</td>
					</tr>
					{{# } }}
			</script>

			<tbody id="list-content"></tbody>
		</table>
	</div>
	<p class="marginRL"><span class="BatchDelete cursor" onclick="BatchDelete()">批量删除</span> <span class="recycleBin cursor">回收站</span></p>

	<!--分页显示-->
	<div class="clearfix" style="float:right;margin: 0 auto;">
		<span class="fl mt5">共<b id="total">{$count}</b>条数据&nbsp;</span><span id="allpage" class="fl  mr20 mt5"></span><span class="fl" id="AjaxPage"></span>
	</div>

</div>
<script>
	function refresh(){
		layer.load(2);
		Ajaxpage();
	}
	//日期选择
	$("#datetimeStart").datetimepicker({
		language: 'cn',
		format: "yyyy-mm-dd",
		autoclose: true,
		minView: "month",
		maxView: "decade",
		todayBtn: true,
		pickerPosition: "bottom-left"
	}).on("click", function(ev) {
		$("#datetimeStart").datetimepicker("setEndDate", $("#datetimeEnd").val());
	});
	$("#datetimeEnd").datetimepicker({
		language: 'cn',
		format: "yyyy-mm-dd",
		autoclose: true,
		minView: "month",
		maxView: "decade",
		todayBtn: true,
		pickerPosition: "bottom-left"
	}).on("click", function(ev) {
		$("#datetimeEnd").datetimepicker("setStartDate", $("#datetimeStart").val());
	});

	function checkbAll(obj) {
		if($(obj).is(":checked")) {
			$(".Subpage").prop("checked", true)
		} else {
			$(".Subpage").prop("checked", false)
		}
	}

	function BatchDelete() {
		if($('.Subpage').is(':checked')) {
			layer.alert("你确定要删除选中的吗?", {
				btn: ['确认', '取消'], //按钮
			}, function() {

				layer.msg('删除成功', {
					time: 1000,
					icon: 1
				});
				sc();
				$(".checkbAll").prop("checked", false)
			});
		} else {
			layer.msg('你还未选中', {
				time: 1000,
				icon: 0
			});
		}
	}

	function sc() {
		$(".Subpage").each(function() {
			if($(this).is(":checked")) {
				$(this).parents("tr").remove();
			}
		})
	}

	$(".operationlog-center>li").click(function() {
		$(this).addClass("operalogCurrent");
		$(this).siblings().removeClass("operalogCurrent");
	})

	Ajaxpage();

	function Ajaxpage(curr) {
		var admin_name = $("#admin_name").val();
		var starting_time = $("#starting_time").val();
		var end_time = $("#end_time").val();
		$.getJSON('{:url("Log/index")}', {
			page: curr || 1,
			admin_name: admin_name,
			starting_time: starting_time,
			end_time: end_time
		}, function(data) {
			$(".spiner-example").css('display', 'none'); //数据加载完关闭动画 
			layer.closeAll('loading');
			if(data == '') {
				$("#list-content").html('<td colspan="20" style="padding-top:10px;padding-bottom:10px;font-size:16px;text-align:center">暂无数据</td>');
			} else if(data.code == 2) {
				layer.msg(e.msg, {
					icon: 2,
					time: 2000
				});
				return;
			} else {
				var tpl = document.getElementById('list-template').innerHTML;
				laytpl(tpl).render(data, function(html) {
					document.getElementById('list-content').innerHTML = html;
				});
				laypage({
					cont: $('#AjaxPage'), //容器。值支持id名、原生dom对象，jquery对象,
					pages: '{$allpage}', //总页数 
					skip: true, //是否开启跳页
					skin: '#337ab7', //分页组件颜色
					curr: curr || 1,
					groups: 3, //连续显示分页数
					jump: function(obj, first) {
						if(!first) {
							Ajaxpage(obj.curr)
						}
						$('#allpage').html('，第' + obj.curr + '页，共' + '<i>' + obj.pages + '</i>' + '页');
						inputlength();
					}
				});
			}
		});
	}
</script>
</body>

</html>